<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 生成器其实就是一个特殊的函数
    // 异步编程 纯回调函数
    function* gen() {
        console.log(arguments[0]);
        yield 11111;
        yield 22222;
        yield 33333;
    }
    let g = gen('mortal');
    console.log(g.next());
    console.log(g.next());
    console.log(g.next());

    // 
    function* gen1() {
        let y1 = yield 11111;
        console.log(y1);
        let y2 = yield 22222;
        console.log(y2);
        let y3 = yield 33333;
        console.log(y3);
    }
    let g1 = gen1();
    g1.next('mortal');
    // next可以传参,第二次传参作为第一次yield的结果
    g1.next('nanfeng'); //第一个yield返回的结果
    g1.next('mingquan'); //第二个yield返回的结果
    g1.next('lanting');  //第三个yield返回的结果

</script>

</html>